package cn.calm.osgi.conter.util;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

import javax.servlet.ServletContext;

public class Resource {
	private static Resource resource;
//	private static String contextPath;
	private Resource (){
		
	}
	
	public static Resource getResource(ServletContext servletContext){
		if(resource==null){
//			contextPath=servletContext.getRealPath("/");
			resource=new Resource();
		}
		return resource;
	}

	public Properties findProperties(String fileName) throws IOException {
		InputStream is= Resource.class.getClassLoader().getResourceAsStream(fileName);
		Properties pro=new Properties();
		pro.load(is);
		return pro;
	}

	public URL find(String dir) {
		return Resource.class.getClassLoader().getResource(dir);
	}
}
